package designPattern.singleton;

/**
 * 饿汉式
 * 简单实用，推荐使用
 * 类加载时就完成实例化
 */
public class singleton01 {
    private static final singleton01 INSTANCE = new singleton01();

    private singleton01() {
    }

    ;

    public static singleton01 getInstance() {
        return INSTANCE;
    }

    public void k() {
        System.out.println("OK");
    }

    public static void main(String[] args) {
        singleton01 s1 = singleton01.getInstance();
        singleton01 s2 = singleton01.getInstance();
        System.out.println(s1 == s2);
    }
}
